var t = getApp();

Page({
    data: {
        option: "",
        mobile: "",
        smsMobile: "",
        imgcode: "",
        imgcodeShow: !1,
        btnText: "获取验证码",
        timer: null,
        btnTag: !1,
        userName: "",
        code: ""
    },
    onLoad: function(t) {
        t.option && (this.setData({
            option: t.option
        }), wx.setNavigationBarTitle({
            title: "phone" == t.option ? "绑定手机" : "实名认证"
        })), t.to && this.setData({
            to: t.to
        });
    },
    confrimBtn: function() {
        var o = this, n = "", e = {};
        "phone" == this.data.option ? (n = t.getNetAddresss("plugin.eplus-pay.frontend.mobile.smsConfirm"), 
        e = {
            mobile: this.data.mobile,
            code: this.data.smsMobile
        }) : (n = t.getNetAddresss("plugin.eplus-pay.frontend.name.nameAuth"), e = {
            name: this.data.userName,
            identity_no: this.data.code
        }), t._getNetWork({
            url: n,
            data: e,
            success: function(n) {
                var e = n.data;
                1 == e.result ? wx.showModal({
                    showCancel: !1,
                    content: e.msg,
                    success: function() {
                        "pay" == o.data.to ? wx.navigateBack({
                            delta: 1
                        }) : wx.redirectTo({
                            url: "/packageF/others/wisdom/wisdomBindTask/wisdomBindTask"
                        });
                    }
                }) : t.tips(e.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    checkCodeMethod: function() {
        this.firstNext();
    },
    firstNext: function() {
        var o = this, n = t.getNetAddresss("plugin.eplus-pay.frontend.mobile.smsCode");
        t._getNetWork({
            url: n,
            data: {
                mobile: this.data.mobile
            },
            success: function(n) {
                var e = n.data;
                1 == e.result ? o.sendCodeAnimation() : t.tips(e.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    sendCodeAnimation: function() {
        var t = this;
        this.data.timer || (this.data.count = 60, wx.showToast({
            title: "验证码已发送",
            icon: "success",
            duration: 1e3
        }), this.data.timer = setInterval(function() {
            t.data.count > 0 && t.data.count <= 60 ? (t.data.count--, t.setData({
                btnTag: !0,
                btnText: t.data.count + "s"
            })) : (t.setData({
                btnTag: !1,
                btnText: "获取验证码"
            }), clearInterval(t.data.timer), t.data.timer = null);
        }, 1e3));
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});